﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Text;
using System.Configuration;
using System.Runtime.Serialization; 
using ZicConsoleApplication.Model;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace ZicConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {

            comm.ClearLogFile();//delete file

            ZIC.ZicWebService zic = new ZIC.ZicWebService();
            zic.Url = "http://218.249.201.46:8899/zic/zicwebservice.asmx";
            #region Checklogin
            comm.WriteLogFile("Checklogin", "", true);
            string Checklogin = ConfigurationSettings.AppSettings["Checklogin"].ToString();
            try
            {
                if (Checklogin == "1")
                {
                    string name = ConfigurationSettings.AppSettings["Checklogin_name"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["Checklogin_pwd"].ToString();
                    string ret = zic.Checklogin(name, pwd);
                    
                    if (ret.ToLower() == "false")
                    {
                        comm.WriteLogFile("Checklogin", "登录失败", false);
                    }
                    else if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("Checklogin", "参数错误", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("Checklogin", "数据有误", false); }
                    else
                    {
                        Model.LoginModel model = (Model.LoginModel)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(Model.LoginModel));
                        comm.WriteLogFile("ID", model.Id, false);
                        comm.WriteLogFile("登录名", model.LoginName, false);
                        comm.WriteLogFile("店名", model.CompanyName, false);
                        comm.WriteLogFile("地址", model.CompanyAddress, false);
                        comm.WriteLogFile("维修站电话", model.CompanyPhone, false);
                    }
                }
                else
                { comm.WriteLogFile("Checklogin", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("Checklogin", ex.Message, false);
            }
            #endregion

            #region GetShopInfoByIds
            comm.WriteLogFile("GetShopInfoByIds", "", true);
            string GetShopInfoByIds = ConfigurationSettings.AppSettings["GetShopInfoByIds"].ToString();
            try
            {
                if (GetShopInfoByIds == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["GetShopInfoByIds_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["GetShopInfoByIds_pwd"].ToString();
                    string ret = zic.GetShopInfoByIds(Pids, pwd);
                    
                    if (ret.ToLower() == "false")
                    {
                        comm.WriteLogFile("GetShopInfoByIds", "身份验证失败", false);
                    }
                    else if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("GetShopInfoByIds", "参数错误", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("GetShopInfoByIds", "数据有误", false); }
                     
                    else
                    {
                        Model.CustominfoModel model = (Model.CustominfoModel)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(Model.CustominfoModel));
                        comm.WriteLogFile("ID", model.Id, false);
                        comm.WriteLogFile("登录名", model.LoginName, false);
                        comm.WriteLogFile("店名", model.CompanyName, false);
                        comm.WriteLogFile("地址", model.CompanyAddress, false);
                        comm.WriteLogFile("维修站电话", model.CompanyPhone, false);
                        comm.WriteLogFile("主要负责人", model.ExcuteMan, false);
                        comm.WriteLogFile("负责人电话", model.LinkPhone, false);
                        comm.WriteLogFile("网址", model.CompanyWebSite, false);
                        comm.WriteLogFile("传真", model.CompanyFax, false);
                    }
                }
                else
                { comm.WriteLogFile("GetShopInfoByIds", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("Checklogin", ex.Message, false);
            }
            #endregion

            #region GetFhList
            comm.WriteLogFile("GetFhList", "", true);
            string GetFhList = ConfigurationSettings.AppSettings["GetFhList"].ToString();
            try
            {
                if (GetFhList == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["GetFhList_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["GetFhList_pwd"].ToString();
                    string Pmaxid = ConfigurationSettings.AppSettings["GetFhList_Pmaxid"].ToString();
                    string ret = zic.GetFhList(Pids, pwd, Convert.ToInt32(Pmaxid));

                    if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("GetFhList", "参数错误", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("GetFhList", "数据有误", false); }
                    else if (ret.ToLower() == "loginerr")
                    { comm.WriteLogFile("GetZYList", "身份验证失败", false); }
                    else
                    {
                        List<Model.FhList> list = (List<Model.FhList>)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(List<Model.FhList>)); if (list.Count <= 0)
                        {
                            comm.WriteLogFile("GetFhList", "无数据", false);
                        }
                        else
                        {
                            int i = 0;
                            comm.WriteLogFile("--------------------共 " + list.Count + " 条-----", "", false);
                            foreach (FhList model in list)
                            {
                                i = i + 1;
                                comm.WriteLogFile("--------------------第 " + i + " 条-----", "", false);
                                comm.WriteLogFile("ID", model.Id, false);
                                comm.WriteLogFile("IDC号", model.Idc, false);
                                comm.WriteLogFile("序列号", model.Xlh, false);
                                comm.WriteLogFile("入库时间", model.Indate, false);
                                comm.WriteLogFile("出库时间", model.Outdate, false);
                                comm.WriteLogFile("销售单号", model.Ss_paper, false);
                                comm.WriteLogFile("最大ID", model.Xsid, false);
                                comm.WriteLogFile("产品型号", model.Cpxh, false);

                            }
                        }
                    }
                }
                else
                { comm.WriteLogFile("GetFhList", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("GetFhList", ex.Message, false);
            }
            #endregion

            #region GetDeviceRecord
            comm.WriteLogFile("GetDeviceRecord", "", true);
            string GetDeviceRecord = ConfigurationSettings.AppSettings["GetDeviceRecord"].ToString();
            try
            {
                if (GetDeviceRecord == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["GetDeviceRecord_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["GetDeviceRecord_pwd"].ToString();
                    string Pmaxid = ConfigurationSettings.AppSettings["GetDeviceRecord_Pmaxid"].ToString();
                    //string ret = zic.GetDeviceRecord(Pids, pwd, Convert.ToInt32(Pmaxid));
                    string ret = zic.GetDeviceRecord(Pids, pwd, 25000);
                    if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("GetDeviceRecord", "参数错误", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("GetDeviceRecord", "数据有误", false); }
                    else if (ret.ToLower() == "loginerr")
                    { comm.WriteLogFile("GetZYList", "身份验证失败", false); }
                    else
                    {
                        List<Model.CarRecordSend> list = (List<Model.CarRecordSend>)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(List<Model.CarRecordSend>));
                        if (list.Count <= 0)
                        {
                            comm.WriteLogFile("GetDeviceRecord", "无数据", false);
                        }
                        else
                        {
                            int i = 0;
                            comm.WriteLogFile("--------------------共 " + list.Count + " 条-----", "", false);
                            foreach (CarRecordSend model in list)
                            {
                                i = i + 1;
                                comm.WriteLogFile("--------------------第 " + i + " 条-----", "", false);
                                comm.WriteLogFile("ID", model.AnchiId.ToString(), false);
                                comm.WriteLogFile("发生故障时间", model.CreateTime, false);
                                comm.WriteLogFile("SIM卡号", model.DeviceId, false);
                                comm.WriteLogFile("DisplayOrder（没用）", model.DisplayOrder.ToString(), false);
                                comm.WriteLogFile("里程", model.Distance.ToString(), false);
                                comm.WriteLogFile("是否事故车", model.IsCrash, false);
                                comm.WriteLogFile("故障码", model.TroubleCodeId, false);
                                comm.WriteLogFile("故障码库", model.TroubleContent, false);
                                comm.WriteLogFile("故障码描述", model.Desc, false);
                            }
                        }
                    }
                }
                else
                { comm.WriteLogFile("GetDeviceRecord", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("GetDeviceRecord", ex.Message, false);
            }
            #endregion

            #region GetTrobuleDevice
            comm.WriteLogFile("GetTrobuleDevice", "", true);
            string GetTrobuleDevice = ConfigurationSettings.AppSettings["GetDeviceRecord"].ToString();
            try
            {
                if (GetTrobuleDevice == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["GetDeviceRecord_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["GetDeviceRecord_pwd"].ToString();
                    string ret = zic.GetTrobuleDevice(Pids, pwd);

                    if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("GetTrobuleDevice", "参数错误", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("GetTrobuleDevice", "数据有误", false); }
                    else if (ret.ToLower() == "loginerr")
                    { comm.WriteLogFile("GetZYList", "身份验证失败", false); }
                    else
                    {
                        List<Model.GpsCarCurrentPosInfoSend> list = (List<Model.GpsCarCurrentPosInfoSend>)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(List<Model.GpsCarCurrentPosInfoSend>));
                        if (list.Count <= 0)
                        {
                            comm.WriteLogFile("GetTrobuleDevice", "无数据", false);
                        }
                        else
                        {
                            int i = 0;
                            comm.WriteLogFile("--------------------共 " + list.Count + " 条-----", "", false);
                            foreach (GpsCarCurrentPosInfoSend model in list)
                            {
                                i = i + 1;
                                comm.WriteLogFile("--------------------第 " + i + " 条-----", "", false);

                                comm.WriteLogFile("CarCondition(没用)", model.CarCondition.ToString(), false);
                                comm.WriteLogFile("车辆状态码", model.CarStatu.ToString(), false);
                                comm.WriteLogFile("方向", model.Direct.ToString(), false);
                                comm.WriteLogFile("卫星收到故障的时间", model.GpsTime, false);
                                comm.WriteLogFile("id", model.Id.ToString(), false);
                                comm.WriteLogFile("最后更新时间", model.LastUpdateTime.ToString(), false);
                                comm.WriteLogFile("经度", model.Latitude.ToString(), false);
                                comm.WriteLogFile("纬度", model.Longitude.ToString(), false);
                                comm.WriteLogFile("写入数据库的时间", model.Recetime, false);
                                comm.WriteLogFile("加速度", model.Speed.ToString(), false);
                                comm.WriteLogFile("是否精确定位", model.StarCondition.ToString(), false);
                                comm.WriteLogFile("星数", model.StarNum.ToString(), false);
                                comm.WriteLogFile("SIM卡号", model.Telephone, false);
                            }
                        }
                    }
                }
                else
                { comm.WriteLogFile("GetTrobuleDevice", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("GetTrobuleDevice", ex.Message, false);
            }
            #endregion

            #region ProductRegister
            comm.WriteLogFile("ProductRegister", "", true);
            string ProductRegister = ConfigurationSettings.AppSettings["ProductRegister"].ToString();
            try
            {
                if (ProductRegister == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["ProductRegister_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["ProductRegister_pwd"].ToString();
                    string PProNum = ConfigurationSettings.AppSettings["ProductRegister_PProNum"].ToString();
                    string Pidc = ConfigurationSettings.AppSettings["ProductRegister_Pidc"].ToString();
                    string PCarNum = ConfigurationSettings.AppSettings["ProductRegister_PCarNum"].ToString();
                    string PowerName = ConfigurationSettings.AppSettings["ProductRegister_PowerName"].ToString();
                    string PTerminalTypeID = ConfigurationSettings.AppSettings["ProductRegister_PTerminalTypeID"].ToString();
                    string PXC = ConfigurationSettings.AppSettings["ProductRegister_PXC"].ToString();
                    string PidCard = ConfigurationSettings.AppSettings["ProductRegister_PidCard"].ToString();
                    string PdeviceType = ConfigurationSettings.AppSettings["ProductRegister_PdeviceType"].ToString();
                    string configType = ConfigurationSettings.AppSettings["ProductRegister_configType"].ToString();

                    string ret = zic.ProductRegister(PProNum, Pidc, Pids, pwd, PCarNum, PowerName, PTerminalTypeID, PXC,
                        Pidc, PdeviceType, configType);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "注册成功", false); break;
                        case "false": comm.WriteLogFile(ret, "注册失败", false); break;
                        case "client_error": comm.WriteLogFile(ret, "已注册过", false); break;
                        case "replace_true": comm.WriteLogFile(ret, "替换成功", false); break;
                        case "replace_false": comm.WriteLogFile(ret, "替换失败", false); break;
                        case "shopid_error": comm.WriteLogFile(ret, "公司不匹配", false); break;
                        case "not_sell": comm.WriteLogFile(ret, "没有销售过", false); break;
                        case "exist": comm.WriteLogFile(ret, "此IDC已存在", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }

                }
                else
                { comm.WriteLogFile("ProductRegister", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("ProductRegister", ex.Message, false);
            }
            #endregion

            #region cancelproductRegister
            comm.WriteLogFile("cancelproductRegister", "", true);
            string cancelproductRegister = ConfigurationSettings.AppSettings["cancelproductRegister"].ToString();
            try
            {
                if (cancelproductRegister == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["cancelproductRegister_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["cancelproductRegister_pwd"].ToString();
                    string Pidc = ConfigurationSettings.AppSettings["cancelproductRegister_Pidc"].ToString();
                    string PProNum = ConfigurationSettings.AppSettings["cancelproductRegister_PProNum"].ToString();
                    string ret = zic.cancelproductRegister(Pidc, Pids, pwd, PProNum);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "取消注册成功", false); break;
                        case "false": comm.WriteLogFile(ret, "取消注册失败", false); break;
                        case "nofit": comm.WriteLogFile(ret, "不存在此IDC", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("cancelproductRegister", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("cancelproductRegister", ex.Message, false);
            }
            #endregion

            #region UpdateCustomInfo
            comm.WriteLogFile("UpdateCustomInfo", "", true);
            string UpdateCustomInfo = ConfigurationSettings.AppSettings["UpdateCustomInfo"].ToString();
            try
            {
                if (UpdateCustomInfo == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["UpdateCustomInfo_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["UpdateCustomInfo_pwd"].ToString();
                    string LoginName = ConfigurationSettings.AppSettings["UpdateCustomInfo_LoginName"].ToString();
                    string CompanyName = ConfigurationSettings.AppSettings["UpdateCustomInfo_CompanyName"].ToString();
                    string ExcuteMan = ConfigurationSettings.AppSettings["UpdateCustomInfo_ExcuteMan"].ToString();
                    string LinkPhone = ConfigurationSettings.AppSettings["UpdateCustomInfo_LinkPhone"].ToString();
                    string CompanyPhone = ConfigurationSettings.AppSettings["UpdateCustomInfo_CompanyPhone"].ToString();
                    string CompanyFax = ConfigurationSettings.AppSettings["UpdateCustomInfo_CompanyFax"].ToString();
                    string CompanyWebSite = ConfigurationSettings.AppSettings["UpdateCustomInfo_CompanyWebSite"].ToString();
                    string CompanyAddress = ConfigurationSettings.AppSettings["UpdateCustomInfo_CompanyAddress"].ToString();
                    string ret = zic.UpdateCustomInfo(Pids, pwd, LoginName, CompanyName, ExcuteMan, LinkPhone, CompanyPhone, CompanyFax, CompanyWebSite, CompanyAddress);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "更新成功", false); break;
                        case "false": comm.WriteLogFile(ret, "更新失败", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("UpdateCustomInfo", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("UpdateCustomInfo", ex.Message, false);
            }
            #endregion

            #region UpdateCustomPass
            comm.WriteLogFile("UpdateCustomPass", "", true);
            string UpdateCustomPass = ConfigurationSettings.AppSettings["UpdateCustomPass"].ToString();
            try
            {
                if (UpdateCustomPass == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["UpdateCustomPass_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["UpdateCustomPass_pwd"].ToString();
                    string newpwd = ConfigurationSettings.AppSettings["UpdateCustomPass_newpwd"].ToString();
                    string ret = zic.UpdateCustomPass(Pids, pwd, newpwd);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "更新成功", false); break;
                        case "false": comm.WriteLogFile(ret, "更新失败", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("UpdateCustomPass", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("UpdateCustomPass", ex.Message, false);
            }
            #endregion

            #region SpecialIDcReg
            comm.WriteLogFile("SpecialIDcReg", "", true);
            string SpecialIDcReg = ConfigurationSettings.AppSettings["SpecialIDcReg"].ToString();
            try
            {
                if (SpecialIDcReg == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["SpecialIDcReg_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["SpecialIDcReg_pwd"].ToString();
                    string Pidc = ConfigurationSettings.AppSettings["SpecialIDcReg_Pidc"].ToString();
                    string ret = zic.SpecialIDcReg(Pids, pwd, Pidc);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "注册成功", false); break;
                        case "false": comm.WriteLogFile(ret, "注册失败", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("SpecialIDcReg", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("SpecialIDcReg", ex.Message, false);
            }
            #endregion

            #region IsSpIDC
            comm.WriteLogFile("IsSpIDC", "", true);
            string IsSpIDC = ConfigurationSettings.AppSettings["IsSpIDC"].ToString();
            try
            {
                if (IsSpIDC == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["IsSpIDC_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["IsSpIDC_pwd"].ToString();
                    string Pidc = ConfigurationSettings.AppSettings["IsSpIDC_Pidc"].ToString();
                    string ret = zic.IsSpIDC(Pids, pwd, Pidc);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "是特殊IDC", false); break;
                        case "false": comm.WriteLogFile(ret, "不是特殊IDC", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("IsSpIDC", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("IsSpIDC", ex.Message, false);
            }
            #endregion

            #region cancelIDcReg
            comm.WriteLogFile("cancelIDcReg", "", true);
            string cancelIDcReg = ConfigurationSettings.AppSettings["cancelIDcReg"].ToString();
            try
            {
                if (cancelIDcReg == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["cancelIDcReg_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["cancelIDcReg_pwd"].ToString();
                    string Pidc = ConfigurationSettings.AppSettings["cancelIDcReg_Pidc"].ToString();
                    string ret = zic.cancelIDcReg(Pids, pwd, Pidc);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "取消成功", false); break;
                        case "false": comm.WriteLogFile(ret, "取消失败", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("cancelIDcReg", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("cancelIDcReg", ex.Message, false);
            }
            #endregion

            #region GetCrash
            comm.WriteLogFile("GetCrash", "", true);
            string GetCrash = ConfigurationSettings.AppSettings["GetCrash"].ToString();
            try
            {
                if (GetCrash == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["GetCrash_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["GetCrash_pwd"].ToString();
                    string MaxDate = ConfigurationSettings.AppSettings["GetCrash_MaxDate"].ToString();
                    string ret = zic.GetCrash(Pids, pwd, Convert.ToDateTime(MaxDate));

                    if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("GetCrash", "参数错误", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("GetCrash", "数据有误", false); }
                    else if (ret.ToLower() == "loginerr")
                    { comm.WriteLogFile("GetCrash", "身份验证失败", false); }
                    else
                    {
                        List<Model.CrashModel> list = (List<Model.CrashModel>)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(List<Model.CrashModel>));
                        if (list.Count <= 0)
                        {
                            comm.WriteLogFile("GetCrash", "无数据", false);
                        }
                        else
                        {
                            int i = 0;
                            comm.WriteLogFile("--------------------共 " + list.Count + " 条-----", "", false);
                            foreach (CrashModel model in list)
                            {
                                i = i + 1;
                                comm.WriteLogFile("--------------------第 " + i + " 条-----", "", false);
                                comm.WriteLogFile("ID", model.Id.ToString(), false);
                                comm.WriteLogFile("IDC号", model.Idc, false);
                                comm.WriteLogFile("救援时间", model.CrashTime, false);

                            }
                        }
                    }
                }
                else
                { comm.WriteLogFile("GetCrash", "此函数已关闭", false); }
                
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("GetCrash", ex.Message, false);
            }
            #endregion

            #region GetCarTyFor1
            comm.WriteLogFile("GetCarTyFor1", "", true);
            string GetCarTyFor1 = ConfigurationSettings.AppSettings["GetCarTyFor1"].ToString();
            try
            {
                if (GetCarTyFor1 == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["GetCarTyFor1_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["GetCarTyFor1_pwd"].ToString();
                    string maxid = ConfigurationSettings.AppSettings["GetCarTyFor1_maxid"].ToString();
                    string ret = zic.GetCarTyFor1(Pids, pwd,Convert.ToInt32( maxid));

                    if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("GetCarTyFor1", "参数错误", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("GetCarTyFor1", "数据有误", false); }
                    else if (ret.ToLower() == "loginerr")
                    { comm.WriteLogFile("GetCarTyFor1", "身份验证失败", false); }
                    else
                    {
                        List<Model.TyModel> list = (List<Model.TyModel>)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(List<Model.TyModel>));
                        if (list.Count <= 0)
                        {
                            comm.WriteLogFile("GetCarTyFor1", "无数据", false);
                        }
                        else
                        {
                            int i = 0;
                            comm.WriteLogFile("--------------------共 " + list.Count + " 条-----", "", false);
                            foreach (TyModel model in list)
                            {
                                i = i + 1;
                                comm.WriteLogFile("--------------------第 " + i + " 条-----", "", false);
                 
                                comm.WriteLogFile("ID", model.AnchiId.ToString(), false);
                                comm.WriteLogFile("厂商", model.Cpai.ToString(), false);
                                comm.WriteLogFile("发动机型号", model.Engine.ToString(), false);
                                comm.WriteLogFile("车型", model.Ty.ToString(), false);
                                comm.WriteLogFile("排量", model.AirDisplacement.ToString(), false);
                                comm.WriteLogFile("备注", model.Remark.ToString(), false);
                                comm.WriteLogFile("里程", model.Ls.ToString(), false);
                                comm.WriteLogFile("保养项目", model.Xlxm.ToString(), false);
                                comm.WriteLogFile("保养周期", model.Bydate.ToString(), false);
                                comm.WriteLogFile("类型", model.Type.ToString(), false);
                            }
                        }
                    }
                }
                else
                { comm.WriteLogFile("GetCarTyFor1", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("GetCarTyFor1", ex.Message, false);
            }
            #endregion

            #region GetCarTy
            comm.WriteLogFile("GetCarTy", "", true);
            string GetCarTy = ConfigurationSettings.AppSettings["GetCarTy"].ToString();
            try
            {
                if (GetCarTy == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["GetCarTy_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["GetCarTy_pwd"].ToString();
                    string MaxDate = ConfigurationSettings.AppSettings["GetCarTy_MaxDate"].ToString();
                    string ret = zic.GetCarTy(Pids, pwd, Convert.ToDateTime(MaxDate));

                    if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("GetCarTy", "参数错误", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("GetCarTy", "数据有误", false); }
                    else if (ret.ToLower() == "loginerr")
                    { comm.WriteLogFile("GetCarTy", "身份验证失败", false); }
                    else
                    {
                        List<Model.CarTyModel> list = (List<Model.CarTyModel>)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(List<Model.CarTyModel>));
                        if (list.Count <= 0)
                        {
                            comm.WriteLogFile("GetCarTy", "无数据", false);
                        }
                        else
                        {
                            int i = 0;
                            comm.WriteLogFile("--------------------共 " + list.Count + " 条-----", "", false);
                            foreach (CarTyModel model in list)
                            {
                                i = i + 1;
                                comm.WriteLogFile("--------------------第 " + i + " 条-----", "", false);
                                comm.WriteLogFile("ID", model.id.ToString(), false);   
                                comm.WriteLogFile("厂商", model.brand.ToString(), false);
                                comm.WriteLogFile("发动机型号", model.Engine_type.ToString(), false);
                                comm.WriteLogFile("车型", model.carType.ToString(), false);
                                comm.WriteLogFile("排量", model.displacement.ToString(), false);
                                comm.WriteLogFile("备注", model.remark.ToString(), false); 
                            }
                        }
                    }
                }
                else
                { comm.WriteLogFile("GetCarTy", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("GetCarTy", ex.Message, false);
            }
            #endregion

            #region GetTymaintain
            comm.WriteLogFile("GetTymaintain", "", true);
            string GetTymaintain = ConfigurationSettings.AppSettings["GetTymaintain"].ToString();
            try
            {
                if (GetTymaintain == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["GetTymaintain_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["GetTymaintain_pwd"].ToString();
                    string MaxDate = ConfigurationSettings.AppSettings["GetTymaintain_MaxDate"].ToString();
                    string ret = zic.GetTymaintain(Pids, pwd, Convert.ToDateTime(MaxDate));

                    if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("GetTymaintain", "参数错误", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("GetTymaintain", "数据有误", false); }
                    else if (ret.ToLower() == "loginerr")
                    { comm.WriteLogFile("GetTymaintain", "身份验证失败", false); }
                    else
                    {
                        List<Model.TymaintainModel> list = (List<Model.TymaintainModel>)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(List<Model.TymaintainModel>));
                        if (list.Count <= 0)
                        {
                            comm.WriteLogFile("GetTymaintain", "无数据", false);
                        }
                        else
                        {
                            int i = 0;
                            comm.WriteLogFile("--------------------共 " + list.Count + " 条-----", "", false);
                            foreach (TymaintainModel model in list)
                            {
                                i = i + 1;
                                comm.WriteLogFile("--------------------第 " + i + " 条-----", "", false);
                               
                                comm.WriteLogFile("ID", model.id.ToString(), false);                                
                                comm.WriteLogFile("车型ID", model.tyid.ToString(), false);
                                comm.WriteLogFile("保养项目", model.MaintainPj.ToString(), false);
                                comm.WriteLogFile("保养周期", model.MaintainPeriod.ToString(), false);
                                comm.WriteLogFile("里程", model.mileage.ToString(), false);
                                comm.WriteLogFile("修改日期", model.modifydate.ToString(), false);
                                comm.WriteLogFile("备注", model.remark.ToString(), false);
                               
                            }
                        }
                    }
                }
                else
                { comm.WriteLogFile("GetTymaintain", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("GetTymaintain", ex.Message, false);
            }
            #endregion

            #region ProductReturn
            comm.WriteLogFile("ProductReturn", "", true);
            string ProductReturn = ConfigurationSettings.AppSettings["ProductReturn"].ToString();
            try
            {
                if (ProductReturn == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["ProductReturn_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["ProductReturn_pwd"].ToString();
                    string Pidc = ConfigurationSettings.AppSettings["ProductReturn_Pidc"].ToString();
                    string PProNum = ConfigurationSettings.AppSettings["ProductReturn_PProNum"].ToString();
                    string ret = zic.ProductReturn(Pids, pwd, PProNum, Pidc);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "取消成功", false); break;
                        case "false": comm.WriteLogFile(ret, "取消失败", false); break;
                        case "noexist": comm.WriteLogFile(ret, "已存在", false); break;
                        case "noidc": comm.WriteLogFile(ret, "没有此IDC", false); break;
                        case "delfail": comm.WriteLogFile(ret, "删除车辆状态失败，也许早以被删除", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("ProductReturn", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("ProductReturn", ex.Message, false);
            }
            #endregion

            #region EditDevice
            comm.WriteLogFile("EditDevice", "", true);
            string EditDevice = ConfigurationSettings.AppSettings["EditDevice"].ToString();
            try
            {
                if (EditDevice == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["EditDevice_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["EditDevice_pwd"].ToString();
                    string Pidc = ConfigurationSettings.AppSettings["EditDevice_Pidc"].ToString();
                    string PProNum = ConfigurationSettings.AppSettings["EditDevice_PProNum"].ToString();
                    string ret = zic.EditDevice(Pids, pwd, PProNum, Pidc);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "转移成功", false); break;
                        case "false": comm.WriteLogFile(ret, "转移失败", false); break;
                        case "idssame": comm.WriteLogFile(ret, "已存在此IDC", false); break;
                        case "nofit": comm.WriteLogFile(ret, "没找到此IDC与序列号", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("EditDevice", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("EditDevice", ex.Message, false);
            }
            #endregion

            #region ChangeSim
            comm.WriteLogFile("ChangeSim", "", true);
            string ChangeSim = ConfigurationSettings.AppSettings["ChangeSim"].ToString();
            try
            {
                if (ChangeSim == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["ChangeSim_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["ChangeSim_pwd"].ToString();
                    string Pidc = ConfigurationSettings.AppSettings["ChangeSim_Pidc"].ToString();
                    string PProNum = ConfigurationSettings.AppSettings["ChangeSim_PProNum"].ToString();
                    string simnum = ConfigurationSettings.AppSettings["ChangeSim_simnum"].ToString();
                    string ret = zic.ChangeSim(Pids, pwd, PProNum, Pidc, simnum);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "更换成功", false); break;
                        case "false": comm.WriteLogFile(ret, "更换失败", false); break;
                        case "norecord": comm.WriteLogFile(ret, "没有此IDC", false); break;
                        case "sim_exist": comm.WriteLogFile(ret, "SIM卡已存在", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("ChangeSim", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("ChangeSim", ex.Message, false);
            }
            #endregion

            #region UpLoadDayInfo
            comm.WriteLogFile("UpLoadDayInfo", "", true);
            //{"Id":0,"Ids":5,"Date":new Date(1296000000000),"Zdc":8,"Sgidc":0,"Bjidc":1,"Byghidc":0,"Bywghidc":0,"Bygzghidc":0,"Bygzwghidc":0,"Nohcidc":0}
            string UpLoadDayInfo = ConfigurationSettings.AppSettings["UpLoadDayInfo"].ToString();
            try
            {
                if (UpLoadDayInfo == "1")
                {
                    string Pdata = ConfigurationSettings.AppSettings["UpLoadDayInfo_Pdata"].ToString();
                    Tbdayinfo model = (Tbdayinfo)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(Pdata, typeof(Tbdayinfo));


                    //comm.WriteLogFile("UpLoadDayInfo", "获取了");
                    dayinfoModel dayinfo = new dayinfoModel();
                    dayinfo.IDS = model.Ids.ToString();
                    dayinfo.Pwd = "1";
                    dayinfo.StatisticsTime = Convert.ToDateTime(DateTime.Now.ToString());
                    dayinfo.register_idc = Convert.ToInt32(model.Zdc);
                    dayinfo.trouble_idc = Convert.ToInt32(model.Sgidc);
                    dayinfo.alarm_idc = Convert.ToInt32(model.Bjidc);
                    dayinfo.conservation_care_idc = Convert.ToInt32(model.Byghidc);
                    dayinfo.conservation_nocare_idc = Convert.ToInt32(model.Bywghidc);
                    dayinfo.conservation_trouble_care_idc = Convert.ToInt32(model.Bygzghidc);
                    dayinfo.conservation_trouble_nocare_idc = Convert.ToInt32(model.Bygzwghidc);
                    dayinfo.noback_idc = Convert.ToInt32(model.Nohcidc);
                    string ret = zic.UpLoadDayInfo(JavaScriptConvert.SerializeObject(dayinfo));
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "上传成功", false); break;
                        case "false": comm.WriteLogFile(ret, "上传失败,今天的数据已上传", false); break; ;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("UpLoadDayInfo", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("UpLoadDayInfo", ex.Message, false);
            }
            #endregion

            #region UpLoadDayTyInfo
            comm.WriteLogFile("UpLoadDayTyInfo", "", true);
            string UpLoadDayTyInfo = ConfigurationSettings.AppSettings["UpLoadDayTyInfo"].ToString();
            try
            {
                if (UpLoadDayTyInfo == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["UpLoadDayTyInfo_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["UpLoadDayTyInfo_pwd"].ToString();
                    string Pdata = ConfigurationSettings.AppSettings["UpLoadDayTyInfo_Pdata"].ToString();
                    List<Model.Tbdaytyinfo> model = (List<Model.Tbdaytyinfo>)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(Pdata, typeof(System.Collections.Generic.List<Model.Tbdaytyinfo>));
                    List<daycartypeModel> list = new List<daycartypeModel>();

                    foreach (Model.Tbdaytyinfo m in model)
                    {
                        daycartypeModel dm = new daycartypeModel();
                        dm.id = m.Id;
                        dm.IDS = m.Ids.ToString();
                        dm.IDCCOUNT = m.Idcn;
                        dm.StatisticsTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
                        dm.Troubletype = m.Gztype;
                        dm.carmodel = m.Ty;
                        list.Add(dm);

                    }
                    string ret = zic.UpLoadDayTyInfo(Pids, pwd, JavaScriptConvert.SerializeObject(list));
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "上传成功", false); break;
                        case "false": comm.WriteLogFile(ret, "上传失败,今天的数据已上传", false); break; ;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("UpLoadDayTyInfo", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("UpLoadDayTyInfo", ex.Message, false);
            }
            #endregion

            #region AddGPRSMessage
            comm.WriteLogFile("AddGPRSMessage", "", true);
            string AddGPRSMessage = ConfigurationSettings.AppSettings["AddGPRSMessage"].ToString();
            try
            {
                if (AddGPRSMessage == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["AddGPRSMessage_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["AddGPRSMessage_pwd"].ToString();
                    string Pdata = ConfigurationSettings.AppSettings["AddGPRSMessage_Pdata"].ToString();
                    string ret = zic.AddGPRSMessage(Pids, pwd, Pdata);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "上传成功", false); break;
                        case "false": comm.WriteLogFile(ret, "上传失败", false); break; ;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("AddGPRSMessage", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("AddGPRSMessage", ex.Message, false);
            }
            #endregion

            #region SmsManage
            comm.WriteLogFile("SmsManage", "", true);
            string SmsManage = ConfigurationSettings.AppSettings["SmsManage"].ToString();
            try
            {
                if (SmsManage == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["SmsManage_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["SmsManage_pwd"].ToString();
                    string type = ConfigurationSettings.AppSettings["SmsManage_type"].ToString();
                    string ret = zic.SmsManage(Pids, pwd, type);
                    
                    if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("SmsManage", "参数错误", false); }
                    else if (ret.ToLower() == "loginerr")
                    { comm.WriteLogFile("SmsManage", "身份验证失败", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("SmsManage", "数据有误", false); }
                    else if (ret.ToLower() == "")
                    {
                        comm.WriteLogFile("SmsManage", "获取失败", false);
                    }
                    else
                    {
                        Model.SmsMangerModel model = (Model.SmsMangerModel)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(Model.SmsMangerModel));
                        comm.WriteLogFile("ID", model.Id.ToString(), false);
                        comm.WriteLogFile("Extend（没用）", model.Extend, false);
                        comm.WriteLogFile("Ids", model.Ids.ToString(), false);
                        comm.WriteLogFile("企业账号", model.Key, false);
                        comm.WriteLogFile("登录名", model.Name, false);
                        comm.WriteLogFile("密码", model.Pass, false);
                        comm.WriteLogFile("类型", model.Type, false);
                    }
                }
                else
                { comm.WriteLogFile("SmsManage", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("SmsManage", ex.Message, false);
            }
            #endregion

            #region GetZYList
            comm.WriteLogFile("GetZYList", "", true);
            string GetZYList = ConfigurationSettings.AppSettings["GetZYList"].ToString();
            try
            {
                if (GetZYList == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["GetZYList_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["GetZYList_pwd"].ToString();
                    string confirmdate = ConfigurationSettings.AppSettings["GetZYList_confirmdate"].ToString();
                    string ret = zic.GetZYList(Pids, pwd, Convert.ToDateTime(confirmdate));
                    
                    if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("GetZYList", "参数错误", false); }
                    else if (ret.ToLower() == "loginerr")
                    { comm.WriteLogFile("GetZYList", "身份验证失败", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("GetZYList", "数据有误", false); }
                    else if (ret.ToString() != "")
                    {
                        List<Model.DeviceModel> list = (List<Model.DeviceModel>)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(List<Model.DeviceModel>));
                        if (list.Count <= 0)
                        {
                            comm.WriteLogFile("GetZYList", "无数据", false);
                        }
                        else
                        {
                            int i = 0;
                            comm.WriteLogFile("--------------------共 " + list.Count + " 条-----", "", false);
                            foreach (DeviceModel model in list)
                            {
                                i = i + 1;
                                comm.WriteLogFile("--------------------第 " + i + " 条-----", "", false);
                                comm.WriteLogFile("ID", model.Id.ToString(), false);
                                comm.WriteLogFile("IDC号", model.DeviceId, false);
                                comm.WriteLogFile("序列号", model.DeviceKey, false);
                                comm.WriteLogFile("所属IDS号", model.ShopId.ToString(), false);
                                comm.WriteLogFile("Extend(没用)", model.Extend, false);
                                comm.WriteLogFile("出库时间", model.OutDate, false);
                                comm.WriteLogFile("最后转移时间", model.LastDate, false);
                                comm.WriteLogFile("确认转移时间", model.ConfirmDate, false);
                                comm.WriteLogFile("转移的IDS号", model.LastIds.ToString(), false);
                                comm.WriteLogFile("状态", model.Status.ToString(), false);
                            }
                        }
                    }
                    else
                    { comm.WriteLogFile("GetZYList", "无数据", false); }

                }
                else
                { comm.WriteLogFile("GetZYList", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("GetZYList", ex.Message, false);
            }
            #endregion

            #region GetDeviceTroubleMessage
            comm.WriteLogFile("GetDeviceTroubleMessage", "", true);
            string GetDeviceTroubleMessage = ConfigurationSettings.AppSettings["GetDeviceTroubleMessage"].ToString();
            try
            {
                if (GetDeviceTroubleMessage == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["GetDeviceTroubleMessage_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["GetDeviceTroubleMessage_pwd"].ToString();
                    string Maxid = ConfigurationSettings.AppSettings["GetDeviceTroubleMessage_Maxid"].ToString();
                    string ret = zic.GetDeviceTroubleMessage(Pids, pwd,Convert.ToInt32(Maxid));

                    if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("GetDeviceTroubleMessage", "参数错误", false); }
                    else if (ret.ToLower() == "loginerr")
                    { comm.WriteLogFile("GetDeviceTroubleMessage", "身份验证失败", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("GetDeviceTroubleMessage", "数据有误", false); }
                    else if (ret.ToString() != "")
                    {
                        List<Model.CarTroubleMessage> list = (List<Model.CarTroubleMessage>)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(List<Model.CarTroubleMessage>));
                        if (list.Count <= 0)
                        {
                            comm.WriteLogFile("GetDeviceTroubleMessage", "无数据", false);
                        }
                        else
                        {
                            int i = 0;
                            comm.WriteLogFile("--------------------共 " + list.Count + " 条-----", "", false);
                            foreach (CarTroubleMessage model in list)
                            {
                                i = i + 1;
                                comm.WriteLogFile("--------------------第 " + i + " 条-----", "", false);
                                comm.WriteLogFile("maxid", model.AnchiId.ToString(), false);
                                comm.WriteLogFile("转速", model.ZS.ToString(), false);
                                comm.WriteLogFile("车速", model.CS.ToString(), false);
                              
                            }
                        }
                    }
                    else
                    { comm.WriteLogFile("GetDeviceTroubleMessage", "无数据", false); }

                }
                else
                { comm.WriteLogFile("GetDeviceTroubleMessage", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("GetDeviceTroubleMessage", ex.Message, false);
            }
            #endregion

            #region QuerySite
            comm.WriteLogFile("QuerySite", "", true);
            string QuerySite = ConfigurationSettings.AppSettings["QuerySite"].ToString();
            try
            {
                if (QuerySite == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["QuerySite_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["QuerySite_pwd"].ToString();
                    string Pidc = ConfigurationSettings.AppSettings["QuerySite_Pidc"].ToString();
                    string ret = zic.QuerySite(Pids, pwd, Pidc);

                    if (ret.ToLower() == "paraerr")
                    { comm.WriteLogFile("QuerySite", "参数错误", false); }
                    else if (ret.ToLower() == "loginerr")
                    { comm.WriteLogFile("QuerySite", "身份验证失败", false); }
                    else if (ret.ToLower() == "err")
                    { comm.WriteLogFile("QuerySite", "数据有误", false); }
                    else if (ret.ToLower() == "noidc")
                    { comm.WriteLogFile("QuerySite", "没有此IDC", false); }

                    else if (ret.ToLower() == "")
                    {
                        comm.WriteLogFile("QuerySite", "获取失败", false);
                    }
                    else
                    {
                        Model.siteModel model = (Model.siteModel)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(ret, typeof(Model.siteModel));
                        comm.WriteLogFile("经度", model.Longitude.ToString(), false);
                        comm.WriteLogFile("纬度", model.Latitude.ToString(), false);
                        
                    }
                }
                else
                { comm.WriteLogFile("QuerySite", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("QuerySite", ex.Message, false);
            }
            #endregion

            #region AddServerTjRecord
            comm.WriteLogFile("AddServerTjRecord", "", true);
            string AddServerTjRecord = ConfigurationSettings.AppSettings["AddServerTjRecord"].ToString();
            try
            {
                if (AddServerTjRecord == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["AddServerTjRecord_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["AddServerTjRecord_pwd"].ToString();
                    string Pdata = ConfigurationSettings.AppSettings["AddServerTjRecord_Pdata"].ToString();

                    string ret = zic.AddServerTjRecord(Pids, pwd, Pdata);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "上传成功", false); break;
                        case "false": comm.WriteLogFile(ret, "上传失败", false); break;
                        case "paraerr": comm.WriteLogFile(ret, "参数错误", false); break;
                        case "null": comm.WriteLogFile(ret, "无数据", false); break;                       
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("AddServerTjRecord", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("AddServerTjRecord", ex.Message, false);
            }
            #endregion

            #region AddTroubleCodeRecord
            comm.WriteLogFile("AddTroubleCodeRecord", "", true);
            string AddTroubleCodeRecord = ConfigurationSettings.AppSettings["AddTroubleCodeRecord"].ToString();
            try
            {
                if (AddTroubleCodeRecord == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["AddTroubleCodeRecord_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["AddTroubleCodeRecord_pwd"].ToString();
                    string Pdata = ConfigurationSettings.AppSettings["AddTroubleCodeRecord_Pdata"].ToString();

                    string ret = zic.AddTroubleCodeRecord(Pids, pwd, Pdata);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "上传成功", false); break;
                        case "false": comm.WriteLogFile(ret, "上传失败", false); break;
                        case "paraerr": comm.WriteLogFile(ret, "参数错误", false); break;
                        case "null": comm.WriteLogFile(ret, "无数据", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("AddTroubleCodeRecord", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("AddTroubleCodeRecord", ex.Message, false);
            }
            #endregion

            #region AddTbnobacktj
            comm.WriteLogFile("AddTbnobacktj", "", true);
            string AddTbnobacktj = ConfigurationSettings.AppSettings["AddTbnobacktj"].ToString();
            try
            {
                if (AddTbnobacktj == "1")
                {
                    string Pids = ConfigurationSettings.AppSettings["AddTbnobacktj_Pids"].ToString();
                    string pwd = ConfigurationSettings.AppSettings["AddTbnobacktj_pwd"].ToString();
                    string Pdata = ConfigurationSettings.AppSettings["AddTbnobacktj_Pdata"].ToString();

                    string ret = zic.AddTbnobacktj(Pids, pwd, Pdata);
                    switch (ret.ToLower())
                    {
                        case "true": comm.WriteLogFile(ret, "上传成功", false); break;
                        case "false": comm.WriteLogFile(ret, "上传失败", false); break;
                        case "paraerr": comm.WriteLogFile(ret, "参数错误", false); break;
                        case "null": comm.WriteLogFile(ret, "无数据", false); break;
                        case "loginerr": comm.WriteLogFile(ret, "登录失败", false); break;
                        case "err": comm.WriteLogFile(ret, "数据有误", false); break;
                    }
                }
                else
                { comm.WriteLogFile("AddTbnobacktj", "此函数已关闭", false); }
            }
            catch (Exception ex)
            {
                comm.WriteLogFile("AddTbnobacktj", ex.Message, false);
            }
            #endregion

            end();
        }

        static void end()
        {
           // Console.SetCursorPosition(0, 3);
            Console.WriteLine(" <程序已运行完毕，请到F://Testlog.txt查看执行结果> ");
            Console.WriteLine(" <按任意键关闭窗口.> ");
            Console.ReadKey(true);

        }
    }
}
